<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>sidebar-menu.js</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
        <h1>
            sidebar-menu.js
        </h1>
        <ul class="files">
            
            <li>
                lib/assets/javascripts/sidebar/sidebar-menu.js
                
            </li>
            <li>Last modified: 2017-01-09 15:37:57 +0800</li>
        </ul>
    </div>

    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>$.sidebarMenu = function(menu) {</p>

<pre><code>var animationSpeed = 300;

$(menu).on(&#39;click&#39;, &#39;li a&#39;, function(e) {
  var $this = $(this);
  var checkElement = $this.next();
  if (checkElement.is(&#39;.treeview-menu&#39;) &amp;&amp; checkElement.is(&#39;:visible&#39;)) {
    checkElement.slideUp(animationSpeed, function() {
      checkElement.removeClass(&#39;menu-open&#39;);
    });
    checkElement.parent(&quot;li&quot;).removeClass(&quot;active&quot;);
  }

  //If the menu is not visible
  else if ((checkElement.is(&#39;.treeview-menu&#39;)) &amp;&amp; (!checkElement.is(&#39;:visible&#39;))) {
    //Get the parent menu
    var parent = $this.parents(&#39;ul&#39;).first();
    //Close all open menus within the parent
    var ul = parent.find(&#39;ul:visible&#39;).slideUp(animationSpeed);
    //Remove the menu-open class from the parent
    ul.removeClass(&#39;menu-open&#39;);
    //Get the parent li
    var parent_li = $this.parent(&quot;li&quot;);

    //Open the target menu and add the menu-open class
    checkElement.slideDown(animationSpeed, function() {
      //Add the class active to the parent li
      checkElement.addClass(&#39;menu-open&#39;);
      parent.find(&#39;li.active&#39;).removeClass(&#39;active&#39;);
      parent_li.addClass(&#39;active&#39;);
    });
  }
  //if this isn&#39;t a link, prevent the page from being redirected
  if (checkElement.is(&#39;.treeview-menu&#39;)) {
    e.preventDefault();
  }
});</code></pre>

<p>}</p>

    </div>
  


  


  
  


  


  

  



  

    

    

    


    


    <!-- Methods -->
              </div>

    </div>
  </body>
</html>
